package com.example.demo.test;

import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.FileInputStream;

@RequestMapping("docx")
@RestController
public class DocxController {

    @RequestMapping("a")
    public String testa() {


        File file = new File("E:/liu/0410new/001/test.docx");
        FileInputStream fis = null;
        XWPFDocument document = null;
        XWPFWordExtractor extractor = null;

        String docx = null;
        try {
            fis = new FileInputStream(file);
            document = new XWPFDocument(fis);
            extractor = new XWPFWordExtractor(document);
            docx = extractor.getText();
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println(docx);
        return docx;


    }


}
